package svc

import (
	"api/internal/config"
	"api/internal/middleware"
	"branding_srv/brandingclient"
	"commerce_srv/commerceclient"
	"github.com/zeromicro/go-zero/rest"
	"github.com/zeromicro/go-zero/zrpc"
	"shopping_srv/shoppingclient"
)

type ServiceContext struct {
	Config      config.Config
	AuthToken   rest.Middleware
	BrandingSrv brandingclient.Branding
	CommerceSrv commerceclient.Commerce
	ShoppingSrv shoppingclient.Shopping
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config:      c,
		AuthToken:   middleware.NewAuthTokenMiddleware().Handle,
		BrandingSrv: brandingclient.NewBranding(zrpc.MustNewClient(c.BrandingSrv)),
		CommerceSrv: commerceclient.NewCommerce(zrpc.MustNewClient(c.CommerceSrv)),
		ShoppingSrv: shoppingclient.NewShopping(zrpc.MustNewClient(c.ShoppingSrv)),
	}
}
